package com.example.project1;

import java.io.Serializable;

public class Student implements Serializable, Comparable<Student> {
  private String id;    // 学号
  private String name;  // 姓名
  private int age;      // 年龄
  private String gender; // 性别
  private double score; // 成绩

  public Student(String id, String name, int age, String gender, double score) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.gender = gender;
    this.score = score;
  }

  // Getters and Setters
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public String getGender() {
    return gender;
  }

  public void setGender(String gender) {
    this.gender = gender;
  }

  public double getScore() {
    return score;
  }

  public void setScore(double score) {
    this.score = score;
  }

  @Override
  public String toString() {
    return String.format("学号: %s, 姓名: %s, 年龄: %d, 性别: %s, 成绩: %.1f",
        id, name, age, gender, score);
  }

  // 按成绩降序排序
  @Override
  public int compareTo(Student o) {
    return Double.compare(o.score, this.score);
  }
}
